package com.thinkgem.jeesite.test.web;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.thinkgem.jeesite.common.web.BaseController;
import com.thinkgem.jeesite.test.entity.TestUser;

import net.sf.json.JSONArray;
import net.sf.json.JSONObject;

@Controller
@RequestMapping(value = "port/test")
public class PortTestController extends  BaseController{

	@RequestMapping("/restFul/{id}/{num}")
	public @ResponseBody String restFul(@PathVariable("id") String id,@PathVariable("num") String num) {
//		String result = "测试";
		Map map = new HashMap<String, String>();
		map.put("name", "小明");
		map.put("pwd", "123");
		map.put("id", id);
		map.put("num", num);
		System.out.println("num="+num);
		TestUser u1 = new TestUser();
		u1.setAuditDepartment("1");
		u1.setDocNumber("1");
		u1.setDocSubtype("1");
		u1.setDocTitle("1");
		u1.setDocType("1");
		u1.setPowerPlant("1");
		u1.setDocPath("C:\\123");
		TestUser u2 = new TestUser();
		u2.setAuditDepartment("2");
		u2.setDocNumber("2");
		u2.setDocSubtype("2");
		u2.setDocTitle("2");
		u2.setDocType("2");
		u2.setPowerPlant("2");
		u2.setDocPath("C:\\123");
		TestUser u3 = new TestUser();
		u3.setAuditDepartment("3");
		u3.setDocNumber("3");
		u3.setDocSubtype("3");
		u3.setDocTitle("3");
		u3.setDocType("3");
		u3.setPowerPlant("3");
		u3.setDocPath("C:\\123");
//		JSONObject jb = JSONObject.fromObject(u1);
		List list = new ArrayList<JSONObject>();
		list.add(JSONObject.fromObject(u1));
		list.add(JSONObject.fromObject(u2));
		list.add(JSONObject.fromObject(u3));
		JSONArray listjsons = JSONArray.fromObject(list);
		String result = "\""+listjsons.toString().replace("\"", "\"\"")+"\"";
		return listjsons.toString();
	}
}
